package cn.edu.cqytxy.cs;

/**
 * 业务逻辑类
 *
 * @author yinjw
 */
public class Service {

    /**
     * 用刀
     *
     * @param gameRole  角色对象(引用传递)
     */
    public static void useKnife(GameRole gameRole) {
        Weapon knife = new Knife();
        knife.setAtt(10);
        knife.setName("大砍刀");
        // 对象类型强转
        Knife temp = (Knife) knife;
        temp.setLength(20);
        gameRole.setWeapon(knife);
        gameRole.useWeapon();
    }

    /**
     * 用枪
     *
     * @param gameRole  角色对象
     */
    public static void useGun(GameRole gameRole) {
        Weapon gun = new Gun();
        gun.setName("突击抢");
        gun.setAtt(100);
        Gun temp = (Gun) gun;
        temp.setNum(20);
        gameRole.setWeapon(temp);
        gameRole.useWeapon();
    }

    public static void main(String[] args) {
        int a = 10;
        test1(a);
        System.out.println(a);

//        GameRole gameRole1 = new GameRole();
//        gameRole1.setHigh(1.8f);
//        test2(gameRole1);
//        System.out.println(gameRole1.getHigh());
    }

    public static void test1(int i) {
        i = 20;
    }

    public static void test2(GameRole gameRole) {
        gameRole.setHigh(2.0f);
    }
}
